import type {
  ProjectApplicationAddDTOType,
  ProjectApplicationUpdateDTOType,
  ProjectApplicationSearchDTOType, AuditApplicationDTOType
} from '@/resources/interface/projectApplication/ProjectApplicationTypes'
import type { ResultTypes } from '@/resources/interface/ResultTypes'
import { HttpResultUtil } from '@/apis/utils/HttpResultUtil'

export class ProjectApplicationApi {
  private static addUrl: string = '/projectApplication/add'
  private static updateUrl: string = '/projectApplication/update'
  private static searchUrl: string = '/projectApplication/search'
  private static deleteUrl: string = '/projectApplication/delete'
  private static applyUrl: string = '/projectApplication/apply'
  private static auditUrl: string = '/projectApplication/audit'

  static audit(data: AuditApplicationDTOType): Promise<ResultTypes> {
    return HttpResultUtil.awaitPost(this.auditUrl, data,true)
  }

  static apply(projectId: number,studentId:number): Promise<ResultTypes> {
    return HttpResultUtil.awaitGet(this.applyUrl, {projectId:projectId,studentId:studentId},true)
  }

  static add(data: ProjectApplicationAddDTOType): Promise<ResultTypes> {
    return HttpResultUtil.awaitPost(this.addUrl, data,true)
  }

  static update(data: ProjectApplicationUpdateDTOType): Promise<ResultTypes> {
    return HttpResultUtil.awaitPost(this.updateUrl, data,true)
  }

  static search(data: ProjectApplicationSearchDTOType): Promise<ResultTypes> {
    return HttpResultUtil.awaitPost(this.searchUrl, data,false)
  }

  static delete(idList: Array<number>): Promise<ResultTypes> {
    return HttpResultUtil.awaitPost(this.deleteUrl, idList,true)
  }
}
